<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://micronova.com/yuzu" prefix="m"%> 
<%@page import = "com.db4o.ext.ExtObjectContainer" %>
<%@page import = "com.db4o.servlet.Db4oServlet" %>
<%@page import = "facades.*" %>
<%@page import = "auser.*" %>
<%@page import = "java.util.*" %>
<%  SessionFacade sfacade = new SessionFacade(session); %>
<jsp:useBean id="editPconti" scope="session" class="auser.PianoDeiConti" />
<%  sfacade.setSessionBean("editPconti",request.getParameterMap()); %>

<c:set var='valid' value='${true}' scope="request" />

<c:if test="${empty param.descrizione}">
	<c:set var='eDescrizione' value='necessario'  scope='request'/>
	<c:set var='valid' value='${false}' />
</c:if>

<c:if test="${(empty param.l1) || param.l1=='0'}">
	<c:set var='eL1' value='necessario'  scope='request'/>
	<c:set var='valid' value='${false}' />
</c:if>
<%   PianoDeiContiCareTaker pct = new PianoDeiContiCareTaker(sfacade.getContainer());   %>
<%   PianoDeiConti vEditPconti = ((PianoDeiConti)session.getAttribute("editPconti"));   %>
<% 	 Circolo c = (Circolo) sfacade.getById(request.getParameter("circoloid"));  		%>
<%	 sfacade.setProperty("editPconti","circolo",c);										%>

<c:if test="${valid}">
	<%   
			
	     	boolean isCopy = false;  
	     	isCopy = pct.isCopy(vEditPconti);
	     	
	     	if(isCopy){
	    	 	request.setAttribute("valid",false);
	    	 	request.setAttribute("mainError","Codice del piano dei conti esistente");
	     	} 
	     	
	 %>
</c:if>

<c:if test="${valid}">
	<%   sfacade.setFromSession("editPconti",true); %> 
	<c:redirect url="/app/start/index.jsp" />
</c:if>

 
<c:if test="${!valid}">
	<jsp:forward page="edit.jsp" />
</c:if>